<template>
  <div style="margin: 0;background-image: url(../../../assets/bgimg.jpg)" >
    <div style="background-color: black;width: 100%;height: 260px; color: beige">
    <div style="margin: 0 auto;text-align: center;line-height: 260px;font-size: 20px">
      小赵测试商场
    </div>
  </div>
<div style="width: 300px;height: 100px;margin: 50px auto;text-align: center;border-radius:15px" >
  <el-form v-model="form" ref="form" >
    <el-form-item >
      <el-input v-model="form.username"></el-input>
    </el-form-item>
    <el-form-item >
      <el-input v-model="form.password"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submitLogin()">登录</el-button>
      <el-button  @click="register()">注册</el-button>
    </el-form-item>
  </el-form>
</div>
<!--    <div style="background-color: black;width: 100%;height:28%; color: beige;margin : 0;position: absolute;bottom: 0">-->

<!--    </div>-->
  </div>
</template>

<script>
import {login} from "../../../api/api";
export default {
name: "Login",
  data(){
  return{
    form:{
      username:'',
      password:''
    }
  }
  },
  methods:{
    submitLogin(){
      let params={
        name:this.form.username,
        password:this.form.password
      }
      console.log(params)
      login(params).then((res=>{
        console.log(res)
        if (res.data.data=="登陆成功"){
          this.$router.push({
            name:'api',
            params:{
              name:this.form.username
            }
          })
        }
      })).catch((res=>{
        console.log(res)
      }))
    }
  }
}
</script>

<style scoped>

</style>